package com.xdj.controller;

import com.xdj.pojo.Result;
import com.xdj.utils.AliOssUtil;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.ResourceBundle;
import java.util.UUID;

/**
 * ClassName: FileUploadController
 * Package: com.xdj.controller
 * Description:
 *
 * @Author: 信
 * @Create: 2024/1/12 - 16:07
 */
public class FileUploadController {

    public Result<String> upload(MultipartFile file) throws IOException {
        String originalFilename = file.getOriginalFilename();

        String filename = UUID.randomUUID().toString()+originalFilename.substring(originalFilename.lastIndexOf("."));

        String url = AliOssUtil.uploadFile(filename, file.getInputStream());

        return Result.success(url);
    }
}
